home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- *
- * Nom: timer.c
- * Desc: handle timer
- *
- *
- * version : $VER: timer.c 1.0 (03.02.98)
- *****************************************************************************
- */
-
- #include <proto/exec.h>
- #include <devices/timer.h>
- #include "utils.h"
- #include "timer.h"
- int initTimer(idWin * prj) {
- // retourne TRUE si initialisation ok
- int ret = FALSE ;
-
- prj->timerok = FALSE ; // ok (pour le refermer)
- if ((prj->trport = CreateMsgPort()) != NULL) {
- // creation port message ok
- if ((prj->treq = CreateIORequest(prj->trport, sizeof(struct timerequest))) != NULL) {
- // creation ioreq ok
- if (!OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest*)prj->treq, 0)) {
- // ouverture timer ok
- ret = TRUE ;
- prj->timerok = TRUE ;
- }
- }
- }
- return ret ;
- }
- void closeTimer(idWin * prj) {
- if (prj->timerok)
- CloseDevice((struct IORequest*)prj->treq) ;
- if (prj->treq)
- DeleteIORequest(prj->treq) ;
- if (prj->trport)
- DeleteMsgPort(prj->trport) ;
- }
- void runtimer(idWin * prj) {
- /* lance le timer
- */
- if (prj->timerok) {
- prj->treq->tr_time.tv_secs = DEFAULT_TIME ;
- prj->treq->tr_time.tv_micro = NULL ;
- prj->treq->tr_node.io_Command = TR_ADDREQUEST ;
- SendIO((struct IORequest *)prj->treq) ;
- }
- }